#include <windows.h>
#include "snake/global.h"
#include "snake/game.h"





void InputScan()
{

    if(game_status == 1) // 游戏开始
    {
        if(GetAsyncKeyState(VK_SPACE))
        {
            game_status = 2;
        }
    }
    else if(game_status == 2) // 游戏中
    {
        if(GetAsyncKeyState(VK_UP))          //按键为向上且当前状态不为向下
        {
            mysnake.motion_dir = 0;
        }
        else if(GetAsyncKeyState(VK_DOWN))   //按键为向下且当前状态不为向上
        {
            mysnake.motion_dir = 1;
        }
        else if(GetAsyncKeyState(VK_LEFT))   //按键为向左且当前状态不为向右
        {
            mysnake.motion_dir = 2;
        }
        else if(GetAsyncKeyState(VK_RIGHT))   //按键为向右且当前状态不为向左
        {
            mysnake.motion_dir = 3;
        }
        else if(GetAsyncKeyState(VK_SPACE))              //暂停
        {
            while(1)
            {
                Sleep(300);
                if(GetAsyncKeyState(VK_SPACE))
                {
                    break;
                }
                if(GetAsyncKeyState(VK_ESCAPE))           //重新开始
                {
                    game_status = 1;
                    break;
                }
            }
        }
        else if(GetAsyncKeyState(VK_ESCAPE))            //退出
        {
            game_status = 1;
        }

    }
    else if(game_status == 3) // 游戏中
    {
        if(GetAsyncKeyState(VK_SPACE))
        {
            game_status = 2;
        }
    }
}
